//@author A0097978X
package flexiCommands;

import logic.EventTypeDeterminer;

public class FlexiCommandGenerator {

	private static final String BY_SPACE_DASH = "(\\s)|[-]";

	private static final int COMMAND = 0;

	private static String[] _userString;
	private static ParseInfo userInfo;
	private static Command cmdObj;

	public static Command generateCommands(String commands) throws IllegalArgumentException, Exception {

		//Logging.log(level.INFO, "user input: " + commands);

		_userString = commands.split(BY_SPACE_DASH);

		switch(EventTypeDeterminer.determineEventType(_userString[COMMAND])) {
			case ADD_TASK:
				userInfo = new ParseAddInfo(_userString);
				break;
			case EDIT_TASK:
				userInfo = new ParseEditInfo(_userString);
				break;
			case DELETE_TASK:
				userInfo = new ParseRemoveInfo(_userString);
				break;
			case DISPLAY:
				userInfo = new ParseDisplayInfo(_userString);
				break;
			case COMPLETE_TASK:
				userInfo = new ParseCompleteInfo(_userString);
				break;
			case PENDING_TASK:
				userInfo = new ParsePendingInfo(_userString);
				break;
			case UNDO:
				userInfo = new ParseUndoInfo(_userString);
				break;
			case REDO:
				userInfo = new ParseRedoInfo(_userString);
				break;
			case EXIT:
				userInfo = new ParseUndoInfo(_userString);
				break;			
			default:
				throw new IllegalArgumentException("Please re-enter your command and queries");
		}

		cmdObj = userInfo.execute();

		return cmdObj;
	}

}
